import React from 'react'

import { BrowserRouter as Router, Route, Switch, Redirect } from 'react-router-dom'

import MyNav from "./components/MyNav" //底部导航栏

import Home from './pages/home'  //首页
import Category from './pages/category'  //分类1
import CategoryT from './pages/categoryT'  //分类2
import Detail from './pages/deatil'  //详情页
import Discover from './pages/discover'  //发现
import Cart from './pages/cart'  //购物车
import My from './pages/my'  //我的页面
import Login from './pages/login' //登录
import More from './pages/more' //更多
import PalSuccess from './pages/palSuccess' //支付成功页面

function AppRouter(props) {
    const navList = [
        {
            "title": "首页",
            "img": "",
            "icon": "icon-icon_sy",
            "selectorIcon": "",
            "router": "/"
        },
        {
            "title": "分类",
            "img": "",
            "icon": "icon-icon_fl",
            "selectorIcon": "",
            "router": "/category"
        },
        {
            "title": "发现更美",
            "img": "https://m.vsigo.cn/static/img/tab_post.png",
            "icon": "",
            "selectorIcon": "",
            "router": "/discover"
        },
        {
            "title": "购物车",
            "img": "",
            "icon": "icon-icon_gwcsy",
            "selectorIcon": "",
            "router": "/cart"
        },
        {
            "title": "我的",
            "img": "",
            "icon": "icon-icon_wd",
            "selectorIcon": "",
            "router": "/my"
        }
    ]
    
    // console.log(1)
    return (
        <Router>
            <Switch>
                <Route path="/" exact={true} component={Home}></Route>
                <Route path="/category" component={Category}></Route>
                <Route path="/categoryT" component={CategoryT}></Route>
                <Route path="/deatil/:id" component={Detail}></Route>
                <Route path="/discover" component={Discover}></Route>
                <Route path="/cart" component={Cart}></Route>
                <Route path="/my" component={My}></Route>
                <Route path="/login" component={Login}></Route>
                <Route path="/more"  render={() => {
                    
                    return localStorage.getItem("token") ? <More></More> : <Redirect to='/login'></Redirect>
                }}></Route>
                 <Route path="/palSuccess"  render={() => {
                    return localStorage.getItem("token") ? <PalSuccess></PalSuccess> : <Redirect to='/login'></Redirect>
                }}></Route>
            </Switch>
            <div>
                <MyNav navList={navList}></MyNav>
            </div>
        </Router>
    )
}
export default AppRouter;